<?php
class ManageSpamForm extends Form{
	function ManageUpTinForm(){
		Form::Form('ManageSpamForm');
		CGlobal::$website_title='Quản trị Spam';
		$this->link_css('style/manage_item.css');
	}

	function draw(){	
		global $display;
		$this->beginForm();
		
		$sql="SELECT COUNT(*) AS total_row FROM spam_content";
		
		$total		=DB::fetch($sql,'total_row',0);
		$pagging	='';
		$spam_contents=array();
		
		if($total){
			$limit='';
			
			$pagging=AZPagging::pagingSE($limit,$total,50,10,'page_no',true);
	
			$sql="SELECT id, des,  subject, content, time, time_modify, status FROM spam_content ORDER BY id DESC $limit";
				
			$re=DB::query($sql);
			
			if($re){
				while($spam=mysql_fetch_assoc($re)){	
					
					if($spam['time'] !=$spam['time_modify']){
						$spam['time']="<b>Tạo:</b> ".date('H\hi d.m.Y',$spam['time']);
						$spam['time'].="<br /><b>Sửa:</b> ".date('H\hi d.m.Y',$spam['time_modify']);
					}
					else{
						$spam['time']="<b>Tạo:</b> ".date('H\hi d.m.Y',$spam['time']);
					}
					
					if($spam['status']==0){	
						$spam['status'] = '<font color="orange">Chưa kích hoạt</font>';
						$spam['check'] = AZLib::button(Url::build_current(array('cmd'=>'active_content','id'=>$spam['id'])),'admin/check.gif','Kích hoạt');
					}
					elseif ($spam['status']==1){
						$spam['status'] = '<font color="red"><b>Kích hoạt</b></font>';	
						$spam['check'] = AZLib::button(Url::build_current(array('cmd'=>'deactive_content','id'=>$spam['id'])),'admin/delete_button_dis.gif','Bỏ kích hoạt');	
					}
					
					$spam['edit_link'] = Url::build_current(array('cmd'=>'edit_content',  'id'=>$spam['id']));
					$spam['del_link']  = Url::build_current(array('cmd'=>'delete_content','id'=>$spam['id']));
					
					$spam['onclick'] 	= Url::open_popup('spam_preview.php?spam_id='.$spam['id'],'600',400,false,false,false,true,false,false,true);

					$spam_contents[] = $spam;															
				}
			}
		}
		
		$display->add('items',$spam_contents);
		$display->add('pagging',$pagging);
		$display->output('ManageSpam');
		$this->endForm();
	}
}
?>